//
//  ZSProgressView.m
//  微博-0C
//
//  Created by 周李波 on 16/7/21.
//  Copyright © 2016年 q. All rights reserved.
//

#import "ZSProgressView.h"

@interface ZSProgressView ()

@property (nonatomic,strong)NSTimer *timer;

@property (nonatomic,assign)BOOL isAnimation;

@end

@implementation ZSProgressView
#pragma mark
#pragma mark - 初始化
- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.tintColor = [UIColor greenColor];
        NSTimer *timer = [[NSTimer alloc]init];
        self.timer = timer;
    }
    return self;
}
#pragma mark
#pragma mark - 动画
- (void)valueChanged{
    if (self.isAnimation) {
        self.progress += 0.05;
        if (self.progress > 0.95) {
            self.progress = 0.95;
        }
    }else{
        if (self.progress == 1) {
            self.hidden = YES;
            [self.timer invalidate];
        }else{
            self.progress += 0.05;
        }
        
    }
    
    
}
#pragma mark
#pragma mark - 开始动画
- (void)startAnimation{
    self.isAnimation = YES;
    self.progress = 0;
    self.hidden = NO;
    self.timer = [NSTimer scheduledTimerWithTimeInterval:1/60 target:self selector:@selector(valueChanged) userInfo:nil repeats:YES];
    
}

#pragma mark
#pragma mark - 结束动画
- (void)endAnimatino{
    self.isAnimation = NO;
}
#pragma mark
#pragma mark - 移除动画
- (void)removeAnimation{
    [self removeFromSuperview];
}
#pragma mark
#pragma mark - 销毁
- (void)dealloc{
    [self.timer invalidate];
}

@end
